<script lang="ts" setup>
import { DefineAdsenseSlot } from "./google-publisher-tag";

defineOptions({
  inheritAttrs: false,
});

withDefaults(
  defineProps<{
    type?: string;
  }>(),
  {
    type: "",
  }
);

const atts = useAttrs();

const refreshId = ref(1);

const isMounted = ref(true);

onMounted(() => {
  isMounted.value = true;
});

onDeactivated(() => {
  isMounted.value = false;
});

onActivated(() => {
  if (!isMounted.value) {
    refreshId.value++;
  }
});
</script>
<template>
  <div v-if="type === 'ads'" class="text-center advert-item">
    <DefineAdsenseSlot v-bind="atts"></DefineAdsenseSlot>
  </div>
  <div v-else class="hidden">
    <slot></slot>
  </div>
</template>
<style lang="scss" scoped>
ins[data-ad-status="unfilled"] {
  display: none !important;
}
</style>
